package com.example.demo.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectRabbitMqConfiguration {
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("direct_order_exchange",true,false);
    }

    @Bean
    public Queue directsmsQueue(){
        return new Queue("sms.direct.queue",true);
    }

    @Bean
    public Queue directduanxinQueue(){
        return new Queue("duanxin.direct.queue",true);
    }

    @Bean
    public Queue directemailQueue(){
        return new Queue("email.direct.queue",true);
    }

    @Bean
    public Binding directsmsBinding(){
        return BindingBuilder.bind(directsmsQueue()).to(directExchange()).with("sms");
    }

    @Bean
    public Binding directduanxinBinding(){
        return BindingBuilder.bind(directduanxinQueue()).to(directExchange()).with("duanxin");
    }

    @Bean
    public Binding directemailBinding(){
        return BindingBuilder.bind(directemailQueue()).to(directExchange()).with("email");
    }
}
